package com.njcky.model.vo;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.njcky.utils.citylife.BigDecimalSerializer;
import com.njcky.utils.citylife.CommonUtil;
import com.yutu.geo4j.DistanceCalculationLine;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @BelongsProject: BladeX-Biz
 * @BelongsPackage: com.yutu.infrastructure.vo
 * @Author: ZYin
 * @CreateTime: 2023-03-16  14:17
 * @Description: TODO
 * @Version: 1.0
 */
@Data
public class CrossSectionAnalysisVo implements Serializable, DistanceCalculationLine {

	private static final long serialVersionUID = -8284205567817154769L;

	public static final Double MIN_GJ = 0.1;
	public static final Double MIDDLE_GJ = 0.2;
	public static final Double MAX_GJ = 0.3;
	public static final Double SUPER_MAX_GJ = 0.4;
	/**
	 * 对象 ID
	 */
	@ApiModelProperty(value = "id")
	private Integer objectid;

	/**
	 * 类型名称
	 */
	@ApiModelProperty(value = "表名")
	private String typeName;

	/**
	 * 普查单元编号
	 */
	@ApiModelProperty(value = "普查单元编号")
	private String pcdybh;

	/**
	 * 标识码
	 */
	@ApiModelProperty(value = "编号")
	private String bsm;
	/**
	 * 要素代码
	 */
	@ApiModelProperty(value = "要素代码")
	private String ysdm;
	/**
	 * 断面尺寸
	 */
	@ApiModelProperty(value = "断面尺寸，单位mm")
	private String dmcc;

	/**
	 * 管径
	 */
	@ApiModelProperty(value = "管径")
	private String gj = "--";
	@ApiModelProperty(value = "原始管径")
	private String ysgj = "--";
	/**
	 * 道路名称
	 */
	@ApiModelProperty(value = "道路名称")
	private String dlmc;

	/**
	 * 管类代码
	 */
	@ApiModelProperty(value = "管类代码")
	private String gldm;

	/**
	 * 材质
	 */
	@ApiModelProperty(value = "材质")
	private String cz;

	/**
	 * 所在道路
	 */
	@ApiModelProperty(value = "所在道路")
	private String szdl;

	/**
	 * 距离
	 */
	@ApiModelProperty(value = "相交的起点到管线的距离,单位m")
	@JsonSerialize(nullsUsing = NullSerializer.class, using = BigDecimalSerializer.class)
	private BigDecimal distance;

	/**
	 * 起点高程
	 */
	@ApiModelProperty(value = "管线起点管道高程")
	@JsonSerialize(nullsUsing = NullSerializer.class, using = BigDecimalSerializer.class)
	private BigDecimal qdgc;

	/**
	 * 终点高程
	 */
	@ApiModelProperty(value = "管线终点管道高程")
	@JsonSerialize(nullsUsing = NullSerializer.class, using = BigDecimalSerializer.class)
	private BigDecimal zdgc;

//	@ApiModelProperty("管径脱密数据")
//	private String gj1;

	@ApiModelProperty("起点埋深")
	protected String qdms;
	/**
	 * 终点埋深
	 */
	@ApiModelProperty("终点埋深")
	protected String zdms;

	@ApiModelProperty("交点坐标")
	private String intersectionPoint;


	@ApiModelProperty("交点埋深")
	private Double intersectionMs;
	@ApiModelProperty("交点高程")
	private Double intersectionGc;
	/**
	 * gxqdfthd
	 */
	@ApiModelProperty(value = "管线起点覆土厚度")
	@JsonSerialize(nullsUsing = NullSerializer.class, using = BigDecimalSerializer.class)
	private BigDecimal gxqdfthd;

	/**
	 * gxzdfthd
	 */
	@ApiModelProperty(value = "管线终点覆土厚度")
	@JsonSerialize(nullsUsing = NullSerializer.class, using = BigDecimalSerializer.class)
	private BigDecimal gxzdfthd;


	/**
	 * 点 GC
	 */
	@ApiModelProperty(value = "管线相交点的高程")
	@JsonSerialize(nullsUsing = NullSerializer.class, using = BigDecimalSerializer.class)
	private BigDecimal pointGc;

	/**
	 * 点 MS
	 */
	@ApiModelProperty(value = "管线相交点的埋深")
	@JsonSerialize(nullsUsing = NullSerializer.class, using = BigDecimalSerializer.class)
	private BigDecimal pointMs;

	/**
	 * 坐标
	 */
	@ApiModelProperty(value = "坐标")
	private String coordinate;

	/**
	 * 点
	 */
	@ApiModelProperty(value = "坐标点")
	private String point;

	/**
	 * 长度
	 */
	@ApiModelProperty(value = "管线长度")
	private String length;


	/**
	 * 获取 WKT
	 *
	 * @return 字符串
	 */
	@Override
	public String getWkt() {
		return coordinate;
	}

	/**
	 * 得到
	 *
	 * @return int
	 */
	@Override
	public int getsrid() {
		return 0;
	}

	public String getYsgj(){
		return this.gj;
	}
	/**
	 * 获取管径
	 *
	 * @return 字符串
	 */
	@Override
	public String getGj() {
		if (StringUtils.isEmpty(this.gj) || this.gj.equals(" ") || this.gj.equals("--")) {
			this.gj = "0.01";
		}
		if (this.gj.equals("小型管") || this.gj.equals("小型管渠")){
			return String.valueOf(MIN_GJ);
		}else if(this.gj.equals("中型管") || this.gj.equals("中型管渠")){
			return String.valueOf(MIDDLE_GJ);
		}else if (this.gj.equals("大型管")){
			return String.valueOf(MAX_GJ);
		}else if (this.gj.equals("特大型管")){
			return String.valueOf(SUPER_MAX_GJ);
		}
		if (this.gj.contains("X")) {
			String hgj;
			String[] strings = this.gj.split("X");
			String gj1 = strings[0];
			String gj2 = strings[1];
			if (Integer.parseInt(gj1) >= Integer.parseInt(gj2)){
				hgj = gj1;
			}else {
				hgj = gj2;
			}
			BigDecimal gjmm = new BigDecimal(hgj).multiply(BigDecimal.valueOf(0.001)).setScale(2, RoundingMode.HALF_UP);
			return gjmm.toString();
		} else if (CommonUtil.isNumeric(this.gj)){
			BigDecimal gjmm = new BigDecimal(this.gj).multiply(BigDecimal.valueOf(0.001)).setScale(2, RoundingMode.HALF_UP);
			return gjmm.toString();
		}else {//中型管
			return this.gj;
		}
	}

	/**
	 * 获取起点海拔高度
	 *
	 * @return 大十进制
	 */
	@Override
	public BigDecimal getStartPointAltitude() {
		return qdgc;
	}

	/**
	 * 获取终点高度
	 *
	 * @return 大十进制
	 */
	@Override
	public BigDecimal getEndPointAltitude() {
		return zdgc;
	}

	/**
	 * 海拔是最高
	 *
	 * @return boolean
	 */
	@Override
	public boolean altitudeIsTop() {
		return false;
	}

	/**
	 * 获取水平直径
	 *
	 * @return 大十进制
	 */
	@Override
	public BigDecimal getDiameterHorizontal() {
		return null;
	}

	/**
	 * 获取垂直直径
	 *
	 * @return 大十进制
	 */
	@Override
	public BigDecimal getDiameterVertical() {
		return null;
	}
}

